package cc.booku.owlbox.loadSqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建数据库sql语句 并 执行
        String sql = "CREATE TABLE IF NOT EXISTS collectTable(id integer primary key autoincrement, vod_score text,vod_name text,vod_class text,vod_pic text,vod_play_url text,vod_add_time text,vod_value_add text)";
        String sql2 = "CREATE TABLE IF NOT EXISTS  loveTable(id integer primary key autoincrement, vod_score text,vod_name text,vod_class text,vod_pic text,vod_play_url text,vod_add_time text,vod_value_add text)";
        String sql3 = "CREATE TABLE IF NOT EXISTS  downTable(id integer primary key autoincrement, vod_score text,vod_name text,vod_class text,vod_pic text,vod_play_url text,vod_add_time text,vod_value_add text)";
        String sql4 = "CREATE TABLE IF NOT EXISTS  userTable(id integer primary key autoincrement, user_name text,user_pwd text,user_phone text,user_imei text)";
        String sql5 = "CREATE TABLE IF NOT EXISTS  recTable(id integer primary key autoincrement,vod_name text)";

        db.execSQL(sql);
        db.execSQL(sql2);
        db.execSQL(sql3);
        db.execSQL(sql4);
        db.execSQL(sql5);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        db.execSQL("DROP TABLE IF EXISTS collectTable");//历史
        db.execSQL("DROP TABLE IF EXISTS loveTable");//收藏
        db.execSQL("DROP TABLE IF EXISTS downTable");//下载
        db.execSQL("DROP TABLE IF EXISTS userTable");//用户
        db.execSQL("DROP TABLE IF EXISTS recTable");//推荐
        onCreate(db);

    }

    //带全部参数的构造函数，此构造函数必不可少
    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

}